<template>
  <button class="qr-button" :class="[`qr-button-${type}`,`qr-button-${size}`,{
    'is-plain': plain, 'is-round': round, 
    'is-circle': circle, 'is-disabled': disabled
  }]" @click="handleClick" @mouseover="mouseover" @mouseout="mouseout" :disabled='disabled'>
    <span v-if="loading" class="qr-button-is-loading"></span>
     <i v-if="icon" :class="`qr-icon-${icon}`"></i>
    <span><slot></slot></span>
  </button>
</template>

<script>
export default {
 name: 'QrButton',
 props: {
   type: {
     type: String,
     default: ''
   },
   plain: {
     type: Boolean,
     default: false
   },
   round: {
     type: Boolean,
     default: false
   },
   circle: {
     type: Boolean,
     default: false
   },
   size: {
     type: String,
     default: ''
   },
   disabled: {
     type: Boolean,
     default: false
   },
   loading: {
     type: Boolean,
     default: false
   },
   icon: {
     type: String,
     default: ''
   }
 },
 methods: {
   handleClick(e) {
     this.$emit('click', e)
   },
   mouseover(e) {
    this.$emit('mouseover', e)
   },
   mouseout(e) {
    this.$emit('mouseout', e)
   }
 }
}
</script>

<style lang="scss" scoped>
  //默认按钮
  .qr-button{
    position: relative;
    display: inline-block;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid #dcdfe6;
    color: #606266;
    -webkit-appearance: none;
    text-align: center;
    box-sizing: border-box;
    outline: none;
    margin: 0;
    transition: 0.1s;
    font-weight: 500;
    //禁止元素的文字被选中
    -moz-user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    padding: 12px 20px;
    font-size: 13px;
    border-radius: 4px;
    &:hover,
    &:focus{
      color: #409eff;
      border-color: #c6e2ff;
      background-color: #ecf5ff;
    }
  }
  //基础按钮
  .qr-button-primary{
  color:#fff;
  background-color: #409eff;
  border-color: #409eff;
  &:hover,
  &:focus{
    background: #66b1ff;
    background-color: #66b1ff;
    color: #fff;
    }
  }
  .qr-button-success{
  color:#fff;
  background-color: #67c23a;
  border-color: #67c23a;
  &:hover,
  &:focus{
    background: #85ce61;
    background-color: #85ce61;
    color: #fff;
    }
  }
  .qr-button-info{
  color:#fff;
  background-color: #909399;
  border-color: #909399;
  &:hover,
  &:focus{
    background: #a6a9ad;
    background-color: #a6a9ad;
    color: #fff;
    }
  }
  .qr-button-warning{
  color:#fff;
  background-color: #e6a23c;
  border-color: #e6a23c;
  &:hover,
  &:focus{
    background: #ebb563;
    background-color: #ebb563;
    color: #fff;
    }
  }
  .qr-button-danger{
  color:#fff;
  background-color: #f56c6c;
  border-color: #f56c6c;
  &:hover,
  &:focus{
    background: #f78989;
    background-color: #f78989;
    color: #fff;
    }
  }
  //朴素按钮
  .qr-button.is-plain{
    &:hover,
    &:focus{
      background: #fff;
      border-color: #489eff;
      color: #409eff;
    }
  }
  .qr-button-primary.is-plain{
    color: #409eff;
    background: #ecf5ff;
    &:hover,
    &:focus{
      background: #409eff;
      border-color: #409eff;
      color: #fff;
    }
  }
  .qr-button-success.is-plain{
    color: #67c23a;
    background: #fff;
    &:hover,
    &:focus{
      background: #67c23a;
      border-color: #67c23a;
      color: #fff;
    }
  }
  .qr-button-info.is-plain{
    color: #909399;
    background: #fff;
    &:hover,
    &:focus{
      background: #909399;
      border-color: #909399;
      color: #fff;
    }
  }
  .qr-button-warning.is-plain{
    color: #e6a23c;
    background: #fff;
    &:hover,
    &:focus{
      background: #e6a23c;
      border-color: #e6a23c;
      color: #fff;
    }
  }
  .qr-button-danger.is-plain{
    color: #f56c6c;
    background: #fff;
    &:hover,
    &:focus{
      background: #f56c6c;
      border-color: #f56c6c;
      color: #fff;
    }
  }
//圆角按钮
.qr-button.is-round{
  border-radius: 20px;
  padding: 12px 23px;
}
//圆形按钮
.qr-button.is-circle{
  border-radius: 50%;
  padding: 15px;
}
//不同大小
.qr-button-big {
   font-size: 23px;
}
.qr-button-small {
  padding: 8px 11px;
  font-size: 13px;
}
.qr-button-mini {
  padding: 5px 7px;
  font-size: 5px;
}
//is-disabled
  .qr-button.is-disabled {
   opacity: .7;
   cursor: no-drop;
   &:hover,
   &:focus{
      color:#606266;
      border-color: #c6e2ff;
      background-color: #ecf5ff;
    }
  }
  .qr-button-primary.is-disabled{
  color:#fff;
  cursor: no-drop;
  border: none;
  background-color: #409eff;
  border-color: #409eff;
  &:hover,
  &:focus{
    background:  #409eff;
    background-color:  #409eff;
    color: #fff;
    }
  }
  .qr-button-success.is-disabled{
      cursor: no-drop;
      color:#fff;
      border: none;
      background-color: #67c23a;
      border-color: #67c23a;
      &:hover,
      &:focus{
        background:  #67c23a;
        background-color: #67c23a;
        color: #fff;
        }
    }
  .qr-button-info.is-disabled{
    cursor: no-drop;
    color:#fff;
    border: none;
    background-color: #909399;
    border-color: #909399;
    &:hover,
    &:focus{
      background:  #909399;
      background-color:  #909399;
      color: #fff;
      }
    }
  .qr-button-warning.is-disabled{
    color:#fff;
    cursor: no-drop;
    border: none;
    background-color: #e6a23c;
    border-color: #e6a23c;
    &:hover,
    &:focus{
      background:  #e6a23c;
      background-color:  #e6a23c;
      color: #fff;
      }
    }
  .qr-button-danger.is-disabled{
    color:#fff;
    border: none;
    cursor: no-drop;
    background-color: #f56c6c;
    border-color: #f56c6c;
    &:hover,
    &:focus{
      background:#f56c6c;
      background-color: #f56c6c;
      color: #fff;
      }
    }
    //朴素禁用
  .qr-button.is-plain.is-disabled{
    &:hover,
    &:focus{
      background: #fff;
      border-color: #489eff;
      color: #409eff;
    }
  }
  .qr-button-primary.is-plain.is-disabled{
    color: #409eff;
    background: #ecf5ff;
    &:hover,
    &:focus{
      background:  #ecf5ff;
      border-color:  #ecf5ff;
      color: #409eff;
    }
  }
  .qr-button-success.is-plain.is-disabled{
    color: #67c23a;
    background: #fff;
    &:hover,
    &:focus{
      background:  #fff;
      border-color: #fff;
      color: #67c23a;
    }
  }
  .qr-button-info.is-plain.is-disabled{
    color: #909399;
    background: #fff;
    &:hover,
    &:focus{
      background:  #fff;
      border-color: #fff;
      color: #909399;
    }
  }
  .qr-button-warning.is-plain.is-disabled{
    color: #e6a23c;
    background: #fff;
    &:hover,
    &:focus{
      background: #fff;
      border-color: #fff;
      color:  #e6a23c;
    }
  }
  .qr-button-danger.is-plain.is-disabled{
    color: #f56c6c;
    background: #fff;
    &:hover,
    &:focus{
      background:#fff;
      border-color:#fff;
      color: #f56c6c;
    }
  }
  //加载中
  .qr-button-is-loading {
    width: 13px;
    height: 13px;
    display: inline-block;
    margin-right: 8px;
    border-radius: 8px; 
    border-color:#40a9ff#40a9ff#40a9ff transparent;
    border-style: solid;
    border-width: 2px;
    animation: qr-span 1s infinite linear;
  }
  @keyframes qr-span {
  0%{transform: rotate(0deg)} 
  100%{transform: rotate(360deg)} 
}
// icon配套样式
.qr-button [class*=qr-icon-]+span{
   margin-left: 5px;
}
</style>
